package newnes.io.fileformats;
/**
 * @(#)INESHeader.java
 *
 *
 * @author DG
 * @version 1.00 2009/3/28
 */
import newnes.MirrorMode;

public class INESHeader extends Header {
	private MirrorMode mirroringMode;
	private boolean trainerEnabled;
	private boolean hasSRAM;
	private int numPRGROMPages;
	private int numCHRROMPages;
	private int numPRGRAMPages;
	private int mapper_number;
	
	/**
	 *Set the mapper number in the header
	 */
	public void setMapperNumber(int mapper){
		mapper_number = mapper;
	}
	
	/**
	 *Get the mapper number from the header
	 */
	 public int getMapperNumber(){
	 	return mapper_number;
	 }
	 
	/**
	 *Set the size of PRG-ROM in terms of 16 kB increments
	 */
	public void setPrgRomSize(int prgROMSize){
		this.numPRGROMPages = prgROMSize;
	}
	
	/**
	 *Set the size of CHR-ROM in terms of 8 kB increments
	 */
	public void setChrRomSize(int chrROMSize){
		this.numCHRROMPages = chrROMSize;
	}
	
	/**
	 *Set the size of PRG-RAM in terms of 8 kB increments
	 */
	public void setPrgRamSize(int prgRAMSize){
		if(prgRAMSize==0){
			prgRAMSize++;
		}
		this.numPRGRAMPages = prgRAMSize;
	}
	
	/**
	 *Set the mirroring mode
	 */
	public void setMirroringMode(MirrorMode mode){
		this.mirroringMode = mode;
	}
	
	/**
	 *Set Trainer Enabled
	 *If true, the nes executable has an additional 512 byte 
	 *segment of memory for a trainer.
	 */
	public void setTrainerEnabled(boolean enable){
		this.trainerEnabled = enable;
	}
	
	/**
	 *Set SRAM enabled,
	 *If true, a segment of the nes executable is reserved for saving
	 *data.
	 */
	public void setBatteryEnabled(boolean enable){
		this.hasSRAM = enable;	
	}
	
	/**
	 *Get the size of PRG-ROM in 16 kB increments
	 */
	public int getPrgRomSize(){
		return numPRGROMPages;
	}
	
	/**
	 *Get the size of CHR-ROM in 8 kB increments
	 */
	public int getChrRomSize(){
		return numCHRROMPages;
	}
	
	/**
	 *Get the size of PRG-RAM in 8 kB increments
	 */
	public int getPrgRamSize(){
		return numPRGRAMPages;
	}
	
	/**
	 *Get the type of mirroring used by this nes executable
	 */
	public MirrorMode getMirroringMode(){
		return mirroringMode;
	}
    
    /**
     *Report whether SRAM is enabled or not.
     */
    public boolean hasSRAM(){
    	return hasSRAM;
    }
    
    /**
     *Report whether this rom has a 512 byte trainer or not
     */
    public boolean hasTrainer(){
    	return trainerEnabled;
    }
    
    public String getFileFormat(){
    	return "INES";
    }  
}
